<!DOCTYPE html>
<html>
<head>
  <title>我的订单</title>
  <meta name="renderer" content="webkit|ie-comp|ie-stand">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <!-- head 中 -->
  <link rel="stylesheet" th:href="@{/jquery-weui/lib/weui.css}">
  <link rel="stylesheet" th:href="@{/jquery-weui/css/jquery-weui.css}">
  <link rel="stylesheet" th:href="@{/jquery-weui/css/demos.css?t=12}">
  <link rel="stylesheet" th:href="@{/css/h5style.css}">
  <style>
    html{
      height: 100%;

    }
    body{
      width: 100%;
      height:100%;
    }
    *{
      margin: 0;
      padding: 0;
    }
    .bd{
      width: 100%;
      height:90%;
      overflow-y: scroll;
    }
    /* 修改标题的文字大小 */
    .weui-dialog__title {
      font-size: 24px;
    }
    .weui-dialog__bd {
      font-size: 20px;
    }
    /* 修改按钮的文字大小和内边距 */
    .weui-dialog__btn {
      font-size: 20px;
      padding: 10px 20px;
    }
  </style>
</head>

<body ontouchstart class="only-bg-color" style="overflow-y: auto">
<input id="xm" name="xm" type="hidden" value="">
<div style="width: 100%;height: 50px;position: fixed;top: 0px;z-index: 999997">
  <table style="height: 55px;width: 100%;background-color: #f3f3f3;">
    <tr><td colspan="3" height="5px;"></td></tr>
    <tr>
      <td style="width: 10%;text-align: center;">&nbsp;<img src="/stamp/image/ht.png" style="width: 25px;height: 25px;" onclick="window.history.back();">&nbsp;</td>
      <td style="width: 10%;text-align: center;">&nbsp;<img src="/stamp/image/zy.png" style="width: 25px;height: 25px;" onclick="zy();">&nbsp;</td>
      <td style="width: 70%"></td>
      <td style="width: 10%;text-align: center">&nbsp;<img src="/stamp/image/sx.png" style="width: 25px;height: 25px;" onclick="window.location.reload()">&nbsp;</td>
    </tr>
  </table>
  <div class="weui-search-bar" id="searchBar" style="background-color: white;border: none;height: 50px;">
    <form class="weui-search-bar__form" autocomplete="off">
      <div class="weui-search-bar__box" style="background-color: #f3f3f3">
        <i class="weui-icon-search"></i>
        <input type="search" class="weui-search-bar__input" style="background-color: #f3f3f3" id="searchInput" name="searchInput" placeholder="请输入订单信息或者活动名称" value="">
        <a href="javascript:" class="weui-icon-clear" id="searchClear" onclick="on_query_cancel();"></a>
      </div>
      <label class="weui-search-bar__label" id="searchText" style="background-color: #f3f3f3">
        <i class="weui-icon-search" style="background-color: #f3f3f3"></i>
        <span>请输入活动名称</span>
      </label>
    </form>
  </div>
</div>
<div style="height: 100px;"></div>
<div id="queryList" class="div-search-result" style="z-index: 999998">
</div>
<input id="pageTotal" name="pageTotal" value="" type="hidden">
<input id="pageCurrent" name="pageCurrent" value="" type="hidden">
<div id="addrList" style="margin: 8px;">

</div>

<div class="page-load" id="loading-div">
  <img id="page-load-img" src="/stamp/image/gif/loading.gif" style="display: none">

</span>
</div>


<div style="height: 130px;"></div>
</body>
<!-- body 最后 -->
<script type="text/javascript" th:src="@{/jquery-weui/lib/jquery-2.1.4.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jquery-weui/lib/fastclick.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jquery-weui/js/jquery-weui.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jsfiles/crypto-js.min.js?t=1}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jsfiles/com.js?t=12}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/layer/layer.js}" charset="utf-8"></script>
<script>
  $(function() {
    FastClick.attach(document.body);
  });
  var adminUrl = "[[${adminUrl}]]";
  //后端地址
  var url = "[[${serverUrl}]]/stamp/h5/api/";
  //图片显示
  var url1 = "[[${serverUrl}]]/stamp/tp/";
  var searchInput="[[${searchInput}]]";
  var xm_id = "[[${xm_id}]]";
  var dz = window.location.href;
  dz = dz.replace(/&/g, "$");
  function init_data(){
    $("#searchInput").val(searchInput);
    $.showLoading("数据加载中...");
    var cxtj;
    if ($("#searchInput").val()==""){
      cxtj = searchInput;
    }else{
      cxtj = $("#searchInput").val();
    }
    var jsonData = {
      dqym:0,
      cxtj:cxtj,
      xm_id:xm_id,
      timestamp:new Date().getTime()
    };
    var sendStr = {
      data:encrypt_str(JSON.stringify(jsonData),localStorage.getItem("a_h5"),localStorage.getItem("b_h5"))
    };
    $.ajax({
      type:"post",
      url:url+"myorder_query",
      data:JSON.stringify(sendStr),
      dataType:"json",
      timeout : 10*1000, //超时时间设置，单位毫秒
      crossDomain: true,
      contentType: 'application/json;charset=UTF-8',
      headers: {
        "token": localStorage.getItem("token_h5")
      },
      beforeSend: function(request) {
        request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
      },
      success:function(result){
        if (result.code==0) {
          let rtn = decrypt_str(result.data, localStorage.getItem("a_h5"), localStorage.getItem("b_h5"));
          console.info("rtn:"+rtn);
          let d = JSON.parse(rtn);
          $("#xm").val(d.xm_id);
          $("#pageTotal").val(d.pageTotal);
          $("#pageCurrent").val(d.pageCurrent);
          var zys = d.pageTotal*1;
          var dqy = d.pageCurrent*1;
          if (dqy<zys){
            var nr = "";
            nr = "<span id=\"page-load-span\" onclick=\"loadNext("+dqy+");\">点击加载下一页</span>";
            $("#loading-div").html(nr)
          }
          var str="";
          if (!is_null(d.stampCardOrderList) && d.stampCardOrderList.length>0){
            d.stampCardOrderList.forEach(function(item){
              str+="  <div class=\"weui-panel weui-panel_access div-yuanjiao\">\n" +
                      "    <div class=\"weui-panel__bd\">\n" +
                      "      <div class=\"weui-media-box weui-media-box_text\">\n" +
                      "        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">活动名称："+item.stampHd.name+"&nbsp;&nbsp;</h4>\n" +
                      "        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">数量："+item.zsl+"&nbsp;&nbsp;费用："+item.jg+"&nbsp;&nbsp;</h4>\n";
              if (item.lqfs=="2"){
                str+="        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">收件信息："+item.lxr+"["+item.lxdhJsm+"]</h4>\n";
                str+="        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">地址："+item.fullDz+"</h4>\n";
              }
              str+="      <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">合计："+item.zjg+"&nbsp;&nbsp;元</h4>\n";
              if (item.isfh=="1"){
                str+="        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">产品状态：<span style='color: #0bb20c'>已发货</span></h4>\n";
                str+="        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">邮件号：["+item.yjhm+"]</h4>\n";
              }else {
                if (item.isfk=="1" && item.istk=="0")
                str+="        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">产品状态：<span style='color: coral'>制作中</span></h4>\n";
              }
              str+=        "    </div>\n" +
                      "  </div>\n" +
                      "  <div class=\"weui-panel__ft\">\n" +
                      "    <div class=\"weui-cell weui-cell_link\">\n" +
                      "      <table style=\"width: 100%;collapse: collapse;border-spacing: 0px;left: 0px;color: #666666\">\n" +
                      "        <tr>\n" +
                      "          <td style='font-size: 13pt'>\n";
              if (item.isfk=="1"){
                if (item.istk=="1")
                {
                  str+="            <span style='color: red'>已退款</sapn>\n";
                }else{
                  str+="            <span style='color: green'>已付款</sapn>\n";
                }
              }else{
                str+="            未付款\n";
              }

                  str+= "          </td>\n" +
                      "          <td style=\"text-align: right\">\n";
              if (item.isfk!="1"){
                str+="            <img src=\"/stamp/image/ico/xiugai.png\" style=\"vertical-align:middle\" width=\"16\" onclick=\"on_fk('"+item.urlId+"')\"><span onclick=\"on_fk('"+item.urlId+"')\" style=\"font-size: 13pt;vertical-align:middle\">去付款</span>&nbsp;\n" +
                        "            <img src=\"/stamp/image/ico/del.png\" style=\"vertical-align:middle\" width=\"16\" onclick=\"on_del('"+item.urlId+"')\"><span onclick=\"on_del('"+item.urlId+"')\" style=\"font-size: 13pt;vertical-align:middle\">删除</span>&nbsp;\n";
              }
                str+="          &nbsp;\n" +
                "          </td>\n" +
                "        </tr>\n" +
                "      </table>\n" +
                "    </div>\n" +
                "  </div>\n" +
                "</div>";
            });
          }else{
            str+="<div style=\"width: 100%;text-align: center;\" id=\"no-data-div\">\n" +
                    "  <div style=\"height: 50px;\"></div>\n" +
                    "  <div><img id=\"page-load-img\" src=\"/stamp/image/ico/kongdizhi.png\" width=\"64\" height=\"64\"></div>\n" +
                    "  <div>没有订单</div>\n" +
                    "</div>";
          }
          $("#queryList").html(str);
          if (!is_null(d.cxtj)){
            $("#searchInput").val(d.cxtj);
          }
        }else{
          $.alert("数据加载发生错误！"+result.msg);
        }
      },
      error:function(result){

      },complete:function(){
        $.hideLoading();
      }
    });
  }

  init_data();

  /*加载下一页*/
  var data_done_str="数据全部加载完成";
  function loadNext(dqym)
  {
    $.showLoading("数据加载中...");
    var searchInput = $("#searchInput").val();
    //显示加载图标，隐藏文字提示div
    $("#page-load-span").hide();
    $("#page-load-img").show();

    var jsonData = {
      dqym:dqym,
      cxtj:searchInput,
      timestamp:new Date().getTime()
    };
    var sendStr = {
      data:encrypt_str(JSON.stringify(jsonData),localStorage.getItem("a_h5"),localStorage.getItem("b_h5"))
    };
    $.ajax({
      type:"post",
      url:url+"myorder_query",
      data:JSON.stringify(sendStr),
      dataType:"json",
      timeout : 10*1000, //超时时间设置，单位毫秒
      crossDomain: true,
      contentType: 'application/json;charset=UTF-8',
      headers: {
        "token": localStorage.getItem("token_h5")
      },
      beforeSend: function(request) {
        request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
      },
      success:function(result){
        if (result.code==0) {
          let rtn = decrypt_str(result.data, localStorage.getItem("a_h5"), localStorage.getItem("b_h5"));
          console.info("rtn:"+rtn);
          let d = JSON.parse(rtn);
          $("#pageTotal").val(d.pageTotal);
          $("#pageCurrent").val(d.pageCurrent);
          var zys = d.pageTotal*1;
          var dqy = d.pageCurrent*1;
          if (dqy<zys){
            var nr = "";
            nr = "<span id=\"page-load-span\" onclick=\"loadNext("+dqy+");\">点击加载下一页</span>";
            $("#loading-div").html(nr)
          }else{
            var nr = "";
            nr = "<span id=\"page-load-span\">数据加载完毕</span>";
            $("#loading-div").html(nr)
          }
          var str="";
          if (!is_null(d.stampCardOrderList) && d.stampCardOrderList.length>0){
            d.stampCardOrderList.forEach(function(item){
              str+="  <div class=\"weui-panel weui-panel_access div-yuanjiao\">\n" +
                      "    <div class=\"weui-panel__bd\">\n" +
                      "      <div class=\"weui-media-box weui-media-box_text\">\n" +
                      "        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">活动名称："+item.stampHd.name+"&nbsp;&nbsp;</h4>\n" +
                      "        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">数量："+item.zsl+"&nbsp;&nbsp;费用："+item.jg+"&nbsp;&nbsp;</h4>\n";
              if (item.lqfs=="2"){
                str+="        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">收件信息："+item.lxr+"["+item.lxdhJsm+"]</h4>\n";
                str+="        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">地址："+item.fullDz+"</h4>\n";
              }
              str+="      <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">合计："+item.zjg+"&nbsp;&nbsp;元</h4>\n";
              if (item.isfh=="1"){
                str+="        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">产品状态：<span style='color: #0bb20c'>已发货</span></h4>\n";
                str+="        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">邮件号：["+item.yjhm+"]</h4>\n";
              }else {
                if (item.isfk=="1" && item.istk=="0")
                  str+="        <h4 class=\"weui-media-box__title\" style=\"color: #333333;font-size: 13pt\">产品状态：<span style='color: coral'>制作中</span></h4>\n";
              }
              str+=        "    </div>\n" +
                      "  </div>\n" +
                      "  <div class=\"weui-panel__ft\">\n" +
                      "    <div class=\"weui-cell weui-cell_link\">\n" +
                      "      <table style=\"width: 100%;collapse: collapse;border-spacing: 0px;left: 0px;color: #666666\">\n" +
                      "        <tr>\n" +
                      "          <td style='font-size: 13pt'>\n";
              if (item.isfk=="1"){
                if (item.istk=="1")
                {
                  str+="            <span style='color: red'>已退款</sapn>\n";
                }else{
                  str+="            <span style='color: green'>已付款</sapn>\n";
                }
              }else{
                str+="            未付款\n";
              }

              str+= "          </td>\n" +
                      "          <td style=\"text-align: right\">\n";
              if (item.isfk!="1"){
                str+="            <img src=\"/stamp/image/ico/xiugai.png\" style=\"vertical-align:middle\" width=\"16\" onclick=\"on_fk('"+item.urlId+"')\"><span onclick=\"on_fk('"+item.urlId+"')\" style=\"font-size: 13pt;vertical-align:middle\">去付款</span>&nbsp;\n" +
                        "            <img src=\"/stamp/image/ico/del.png\" style=\"vertical-align:middle\" width=\"16\" onclick=\"on_del('"+item.urlId+"')\"><span onclick=\"on_del('"+item.urlId+"')\" style=\"font-size: 13pt;vertical-align:middle\">删除</span>&nbsp;\n";
              }
              str+="          &nbsp;\n" +
                      "          </td>\n" +
                      "        </tr>\n" +
                      "      </table>\n" +
                      "    </div>\n" +
                      "  </div>\n" +
                      "</div>";
            });
          }else{
            str+="<div style=\"width: 100%;text-align: center;\" id=\"no-data-div\">\n" +
                    "  <div style=\"height: 50px;\"></div>\n" +
                    "  <div><img id=\"page-load-img\" src=\"/stamp/image/ico/kongdizhi.png\" width=\"64\" height=\"64\"></div>\n" +
                    "  <div>没有订单</div>\n" +
                    "</div>";
          }
          $("#queryList").append(str);
        }
      },
      error:function(result){

      },complete:function(){
        $.hideLoading();
      }
    });
  }

  /*修改地址,增加一个回调区分的名称*/
  function on_fk(id)
  {
    parent.location.href=adminUrl+"/h5/pay/info?&id="+id;
  }
  /*删除地址,增加一个回调区分的名称*/
  function on_del(id)
  {
    if (!confirm("是否删除？")) return false;
    $.showLoading("删除中");
    var jsonData = {
      id:id,
      timestamp:new Date().getTime()
    };
    var sendStr = {
      data:encrypt_str(JSON.stringify(jsonData),localStorage.getItem("a_h5"),localStorage.getItem("b_h5"))
    };
    /*删除 ajax调用删除*/
    $.ajax({
      url: url+"myorder_del",
      type: 'POST',
      data:JSON.stringify(sendStr),
      timeout : 10*1000, //超时时间设置，单位毫秒
      crossDomain: true,
      contentType: 'application/json;charset=UTF-8',
      headers: {
        "token": localStorage.getItem("token_h5")
      },
      beforeSend: function(request) {
        request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
      },
      error: function(XMLHttpRequest, textStatus, errorThrown)
      {
        $.hideLoading();
      },
      success: function(str)
      {
        $.hideLoading();
        init_data();
      }
    });
  }

  function zy(){
    parent.location.href=adminUrl+"/h5/myhome/index?id="+$("#xm").val();
  }
</script>

</body>
</html>
